template <class ItemType>
EnhancedQueue<ItemType>::EnhancedQueue()
// Class constructor.
{
	
}

template <class ItemType>
EnhancedQueue<ItemType>::~EnhancedQueue()
// Class destructor.
{
	
}

template <class ItemType>
EnhancedQueue<ItemType>::EnhancedQueue(const EnhancedQueue &orig)
//copy constructor
{
	queueData = orig.queueData;
}

template <class ItemType>
EnhancedQueue<ItemType> EnhancedQueue<ItemType>::operator=(const EnhancedQueue<ItemType>& rhs)
//assignment operator
{
	queueData = rhs.queueData;

	return *this;
}

template <class ItemType>
int EnhancedQueue<ItemType>::Length() const
//returns queue length
{
	return queueData.size();
}

template <class ItemType>
void EnhancedQueue<ItemType>::Clear()
//clears queue
{
	queueData.clear();
}

template <class ItemType>
void EnhancedQueue<ItemType>::MoveLastToFront()
//moves last item to front of queue
{
	//check cases which would have no change
	if (queueData.size() == 0 || queueData.size() == 1)
		return;
	else
	{
		list<ItemType>::iterator last;
		last = queueData.end();
		last--;
		queueData.insert(queueData.begin(), *last);
		queueData.pop_back();
	}
}

template <class ItemType>
bool EnhancedQueue<ItemType>::Move(int from, int to)
//moves item to a different position
{
	//check for illegal values
	if(from > (int) queueData.size() || to > (int) queueData.size() || from < 1 || to < 1)
		return false;
	else
	{
		//if positions are the same, do nothing
		if ( to == from)
			return true;

		list<ItemType>::iterator fromItr;
		list<ItemType>::iterator toItr;

		ItemType tempItem;

		fromItr = queueData.begin();
		int pos;
		for (pos = 1; pos < from; pos++)
			fromItr++;

		tempItem = *fromItr;
		queueData.erase(fromItr);

		toItr = queueData.begin();
		for (pos = 1; pos < to; pos++)
			toItr++;

		queueData.insert(toItr,tempItem);

		return true;
	}
}

template <class ItemType>
void EnhancedQueue<ItemType>::Enqueue(ItemType item)
//enqueues an item at the end of the queue
{
	queueData.push_back(item);
}

template <class ItemType>
int EnhancedQueue<ItemType>::Find(ItemType item)
//finds and item in the queue
{
	int pos = 0;

	list<ItemType>::iterator current;
	
	//search the queue for the item
	for(current = queueData.begin(); current != queueData.end(); current++)
	{
		pos++;
		//if found return it's position
		if(*current == item)
			return pos;
	}
	return -1;
}

template <class ItemType>
void EnhancedQueue<ItemType>::Dequeue(ItemType &item)
//dequeues the first position in the queue
{
	item = queueData.front();
	queueData.pop_front();
}

template <class ItemType>
void EnhancedQueue<ItemType>::Print(ostream &out)
//prints a list of the elements in the queue
{
	list<ItemType>::iterator current;
	current = queueData.begin();

	while(current != queueData.end())
	{
        out << *current << endl;
		current++;
	}
}

template <class ItemType>
bool EnhancedQueue<ItemType>::Delete(int pos, ItemType &item)
//deletes an item in the queue
{
	//check for invalid positions
	if(pos > queueData.size() || pos < 1)
		return false;
	else
	{
		list<ItemType>::iterator current;
		current = queueData.begin();

		for (int i = 1; i < pos; i++)
			current++;
		item = *current;
		queueData.erase(current);
	}
	return true;
}